﻿using System;
using System.IO;
using System.Xml;

namespace WindowsApplication1.commen
{
    public class xml_help
    {
        public static string get_AppName()
        {
            //string strPath = "";
            string strPath = Path.Combine(Environment.CurrentDirectory, "Xml/Config.xml");
            //string strPath = Path.Combine("Xml/Config.xml");
            XmlDocument doc = new XmlDocument();
            doc.Load(strPath);
            XmlNodeList nodeList = doc.SelectSingleNode("data").ChildNodes;

            foreach (XmlNode xn in nodeList)
            {
                if (xn.Name == "row")
                {
                    if (xn["AppName"] != null)
                    {
                        return xn["AppName"].InnerText.ToString();
                    }
                    //foreach (XmlNode xn1 in xn.ChildNodes)
                    //{
                    //    if (xn1.Name == "AppName")
                    //    {
                    //        this.Text = xn1.InnerText;
                    //        break;
                    //    }
                    //    else if (xn1.Name == "green")
                    //    {
                    //        strGreen = xn1.InnerText;
                    //        break;
                    //    }
                    //}
                }
            }
            return "";
        }

        public static string get_greensoft()
        {
            //string strPath = "";
            string strPath = Path.Combine(Environment.CurrentDirectory, "Xml/Config.xml");
            //string strPath = Path.Combine("Xml/Config.xml");
            XmlDocument doc = new XmlDocument();
            doc.Load(strPath);
            XmlNodeList nodeList = doc.SelectSingleNode("data").ChildNodes;

            foreach (XmlNode xn in nodeList)
            {
                if (xn.Name == "row")
                {
                    if (xn["green"] != null)
                    {
                        return xn["green"].InnerText.ToString();
                    }
                }
            }
            return "";
        }

        public static string get_time()
        {
            string strPath = Path.Combine(Environment.CurrentDirectory, "Xml/Config.xml");
            XmlDocument doc = new XmlDocument();
            doc.Load(strPath);
            XmlNodeList nodeList = doc.SelectSingleNode("data").ChildNodes;

            foreach (XmlNode xn in nodeList)
            {
                if (xn.Name == "row")
                {
                    if (xn["time"] != null)
                    {
                        return xn["time"].InnerText.ToString();
                    }
                }
            }
            return "";
        }

        public static string get_server()
        {
            string strPath = Path.Combine(Environment.CurrentDirectory, "Xml/Config.xml");
            XmlDocument doc = new XmlDocument();
            doc.Load(strPath);
            XmlNodeList nodeList = doc.SelectSingleNode("data").ChildNodes;

            foreach (XmlNode xn in nodeList)
            {
                if (xn.Name == "row")
                {
                    if (xn["server"] != null)
                    {
                        return xn["server"].InnerText.ToString();
                    }
                }
            }
            return "";
        }
    }
}